package com.hzcx.app.simplechat.ui.friend.presenter;

import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.model.FriendModel;
import com.hzcx.app.simplechat.ui.friend.bean.FriendBean;
import com.hzcx.app.simplechat.ui.friend.bean.FriendLableInfoBean;
import com.hzcx.app.simplechat.ui.friend.contract.FriendContract;
import com.hzcx.app.simplechat.ui.friend.contract.FriendLableInfoContract;
import com.hzcx.app.simplechat.ui.main.bean.FriendRequestCountBean;
import com.hzcx.app.simplechat.util.log.LogUtils;

import java.util.List;

public class FriendLableInfoPresenter extends BasePresenter<FriendLableInfoContract.View> implements FriendLableInfoContract.Presenter {


    /**
     * 创建或修改标签
     *
     * @param context
     * @param list
     * @param name
     * @param lable_id
     */
    @Override
    public void createFriendLable(Context context, List<FriendBean> list, String name, String lable_id) {
        String ids = "";

        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == null || list.get(i).getCity() == null || list.get(i).getCity().size() <= 0) {
                continue;
            }
            for (int j = 0; j < list.get(i).getCity().size(); j++) {
                ids = ids + list.get(i).getCity().get(j).getMember_id() + ",";
            }
        }

        LogUtils.d("ids:"+ids);

        FriendModel.createFriendLable(context, ids, name, lable_id, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.createSuccess();
            }
        });
    }

    /**
     * 获取标签详情
     * @param context
     * @param lable_id
     */
    @Override
    public void getFriendLableInfo(Context context, String lable_id) {
        FriendModel.getFriendLableInfo(context, lable_id, new BaseDialogObserver<FriendLableInfoBean>(context) {
            @Override
            protected void onSuccess(FriendLableInfoBean data) {
                mView.lableResult(data);
            }
        });
    }
}
